import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common';
import { CreateMoneyDto } from './dto/create-money.dto';
import { MoneyService } from './money.service';
import { UpdateMoneyDto } from './dto/update-money.dto';
import { ReqUser } from '../../../common/decorator/user.decorator';

@Controller()
export class MoneyController {
  constructor(private readonly moneyService: MoneyService) {}

  @Post()
  create(@Body() createMoneyDto: CreateMoneyDto) {
    return this.moneyService.create(createMoneyDto);
  }

  @Post('sign')
  sign(@ReqUser('id') userId: number) {
    return this.moneyService.sign(userId);
  }

  @Get('list')
  findAll(@ReqUser('id') userId: number) {
    return this.moneyService.findAll(userId);
  }

  @Patch(':id')
  update(@Param('id') id: number, @Body() updateMoneyDto: UpdateMoneyDto) {
    return this.moneyService.update(id, updateMoneyDto);
  }

  @Delete(':id')
  remove(@Param('id') id: number) {
    return this.moneyService.remove(id);
  }
}
